<?php

namespace Database\Seeders;

use App\Kuafu\Mqtt\Model\Log;
use App\Library\SnowFlake\SnowFlake;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

class MqttLogSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $insertArr = [
            [
                'id'        => SnowFlake::nextIdCache(),
                'cmd'       => uniqid('cmd-'),
                'status'    => 1,
                'params'    => '',
                'createdAt' => time(),
                'updatedAt' => 0
            ],
            [
                'id'        => SnowFlake::nextIdCache(),
                'cmd'       => uniqid('cmd-'),
                'status'    => 1,
                'params'    => '',
                'createdAt' => time(),
                'updatedAt' => 0
            ],
            [
                'id'        => SnowFlake::nextIdCache(),
                'cmd'       => uniqid('cmd-'),
                'status'    => 1,
                'params'    => '',
                'createdAt' => time(),
                'updatedAt' => 0
            ],
            [
                'id'        => SnowFlake::nextIdCache(),
                'cmd'       => uniqid('cmd-'),
                'status'    => 1,
                'params'    => '',
                'createdAt' => time(),
                'updatedAt' => 0
            ],
            [
                'id'        => SnowFlake::nextIdCache(),
                'cmd'       => uniqid('cmd-'),
                'status'    => 1,
                'params'    => '',
                'createdAt' => time(),
                'updatedAt' => 0
            ],
            [
                'id'        => SnowFlake::nextIdCache(),
                'cmd'       => uniqid('cmd-'),
                'status'    => 1,
                'params'    => '',
                'createdAt' => time(),
                'updatedAt' => 0
            ],
        ];

        $table = Log::query()->getModel()->getTable();
        DB::table($table)->truncate();
        DB::table($table)->insert($insertArr);
    }
}
